<?php

//this file imports an uploaded database in the same direcory as the root files.
//This will only import NEW data, it will not import changed data!!!!!!!!! Nor deleted data. If you use quran.sql, if you want to delete the old and import new, use qurandrop.sql
include '../settings.php'; 
$con=mysqli_connect($host,$dbuserW,$dbpassW,$dbname);


//only execute if correct pass is given
if ($_GET['do']==$dbpassR)
{

$filename = '../quran.sql';



// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line)
{
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
    continue;

// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
{
    // Perform the query
    mysqli_query($con,$templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
    // Reset temp variable to empty
    $templine = '';
}
}
 echo "Tables imported successfully";
 
 
}
?>